/**
* Created by Administrator on 2025/5/7.
* */
#include "AppDelegate.h"
#include "GlobalParameters.h"
#include <string>
#include "AIE2E/AIE2E.h"
#include "MyDeviceReader/MyDeviceReader.h"
#include "Track/Track.h"
#include "Spot/Spot.h"
#include "MyDeviceWriter/MyDeviceWriter.h"
#include "AIE2EMonitor/AIE2EMonitor.h"
#include "MyDeviceReader_1/MyDeviceReader_1.h"
#include "MyDeviceReader_3/MyDeviceReader_3.h"
#include "AIE2EInferController/AIE2EInferController.h"
#include "EthernetReader.h"
#include "EthernetWriter.h"

void AppDelegate::onConfigure(device_config_t *config){
    config->calculationPoolSize=8;
    config->globalParametersInstance = GlobalParameters::shareInstance();
    config->deviceId=4;
    config->servicePort=55261;
    config->ip="192.168.1.115";
    config->userVersion="1.0";
}

void AppDelegate::onStart(){
    REGISTER_RUNTIME_LOADED_CLASSES(AIE2E,MyDeviceReader,MyDeviceReader_3,Track,MyDeviceWriter,Spot,AIE2EMonitor,MyDeviceReader_1,AIE2EInferController);
    auto aiE2E = new AIE2E();
    auto track = new Track();
    auto sopt = new Spot();
    auto aiE2EMonitor = new AIE2EMonitor();
    auto aiE2EInferController = new AIE2EInferController();

    auto radarlabReader = new MyDeviceReader();
    radarlabReader->addTaskModule(aiE2E,0,1024);
    radarlabReader->addTaskModule(aiE2EInferController,0,1024);

    auto radarlabReader_3 = new MyDeviceReader_1();
    radarlabReader_3->addTaskModule(aiE2EMonitor,0,1024);

    auto radarlabReader_1 = new MyDeviceReader_3();
    radarlabReader_1->addTaskModule(aiE2E,1,1024);

    auto radarlabReader_2 = new EthernetReader(TCP,6677);
    radarlabReader_2->addTaskModule(aiE2EInferController,1,1024);

    sopt->addOutput(0,0,track,1024);
    aiE2E->addOutput(0,0,sopt,1024);
    aiE2E->addOutput(1,1,aiE2EMonitor,1024);

    aiE2EInferController->setLaunchPolicy(LaunchMode_OR,LaunchCondition());

    auto radarlabWriter = new MyDeviceWriter();
    track->addDeviceWriter(0,radarlabWriter,1024);

    auto radarlabWriter_2 = new MyDeviceWriter();
    track->addDeviceWriter(1,radarlabWriter_2,1024);

    auto radarlabWriter_1 = new MyDeviceWriter();
    sopt->addDeviceWriter(1,radarlabWriter_1,1024);

    auto radarlabWriter_3 = new MyDeviceWriter();
    aiE2EMonitor->addDeviceWriter(0,radarlabWriter_3,1024);

    auto radarlabWriter_4 = new MyDeviceWriter();
    aiE2EInferController->addDeviceWriter(0,radarlabWriter_4,1024);

    auto radarlabWriter_5 = new EthernetWriter(TCP,"192.168.1.115",6678,true);
    aiE2EMonitor->addDeviceWriter(1,radarlabWriter_5,1024);
    REGISTER_INSTANCES(aiE2E,radarlabReader,radarlabReader_1,track,radarlabWriter,radarlabWriter_2,sopt,radarlabWriter_1,aiE2EMonitor,radarlabReader_3);
    REGISTER_INSTANCES(radarlabWriter_3,radarlabWriter_5,aiE2EInferController,radarlabReader_2,radarlabWriter_4);
}
